package com.yawn.zddefect.controller;

import com.yawn.zddefect.controller.entity.RestResponse;
import com.yawn.zddefect.entity.Defect;
import com.yawn.zddefect.service.DefectService;
import com.yawn.zddefect.util.WebUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @author Created by yawn on 2018-01-30 17:42
 */
@RestController
public class DefectController {

    @Resource
    private DefectService defectService;

    @PostMapping("/defect/start")
    public RestResponse startDefect(@RequestBody Defect defect, @RequestParam("userId") String userId) {
        return defectService.startDefect(userId, defect);
    }

    @GetMapping("/task/todo")
    public RestResponse todoTask(String userId) {
        return defectService.todoTask(userId);
    }

    @PostMapping("/set/assignee")
    public RestResponse setAssignee(@RequestBody Defect defect, String userId) {
        return defectService.setAssignee(userId, defect);
    }

    @PostMapping("/do/task")
    public RestResponse doTask(@RequestBody Defect defect, String userId) {
        return defectService.doTask(userId, defect);
    }

    @PostMapping("/defect/revise")
    public RestResponse reviseDefect(@RequestBody Defect defect, String userId) {
        return defectService.reviseDefect(userId, defect);
    }

    @PostMapping("/comment/add")
    public RestResponse addComment(String userId, String taskId, String comment) {
        return defectService.addComment(userId, taskId, comment);
    }

    @GetMapping("/comment/list")
    public RestResponse getComment(String taskId) {
        return defectService.getProcessInstanceComment(taskId);
    }

    @PostMapping("/attachment/add")
    public void addAttachment(String taskId, String attachName){
        defectService.addAttachment(taskId, attachName);
    }

}

